package com.hsjk.szwj.module.pay.api;

import com.hsjk.szwj.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.hsjk.szwj.framework.tenant.core.aop.TenantIgnore;
import com.hsjk.szwj.module.pay.api.dto.MchDivisionReceiverDTO;
import com.hsjk.szwj.module.pay.convert.DivisionConvert;
import com.hsjk.szwj.module.pay.dal.dataobject.division.MchDivisionReceiverDO;
import com.hsjk.szwj.module.pay.dal.mysql.IMchDivisionReceiverMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/12/04 23:40
 **/
@Service
public class MchDivisionReceiverApiImpl implements IMchDivisionReceiverApi {
    @Resource
    private IMchDivisionReceiverMapper mchDivisionReceiverMapper;

    @Override
    @TenantIgnore
    public MchDivisionReceiverDTO getMchDivisionReceiverById(Long id) {
        MchDivisionReceiverDO mchDivisionReceiverDO = mchDivisionReceiverMapper.selectById(id);
        return DivisionConvert.INSTANCE.convertMchDivisionReceiverDTO(mchDivisionReceiverDO);
    }

    @Override
    @TenantIgnore
    public MchDivisionReceiverDTO getMchDivisionReceiverByTenantId(Long tenantId) {
        MchDivisionReceiverDO mchDivisionReceiverDO = mchDivisionReceiverMapper.selectOne(new LambdaQueryWrapperX<MchDivisionReceiverDO>()
                .eq(MchDivisionReceiverDO::getTenantId, tenantId));
        return DivisionConvert.INSTANCE.convertMchDivisionReceiverDTO(mchDivisionReceiverDO);
    }
}
